<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up()
    : void
    {
        Schema::create('vote_options',function(Blueprint $table) {

            // 数据类型
            $table->engine = 'InnoDB';

            $table->comment('投票配置选项表');

            $table->increments('id');
            $table->foreignUuid('vote_id')->nullable(false)->comment('对应投票ID');
            $table->foreignUuid('options_id')->nullable(false)->unique();
            $table->string('title',125)->nullable(false)->unique();
            $table->integer('sort_id')->nullable()->unsigned()->default(1)->comment('排序');
            $table->integer('number_id')->unsigned()->default(1)->comment('序列号');
            $table->integer('accumulate_id')->nullable()->unsigned()->default(0)->comment('累计票数');
            $table->integer('visits_id')->nullable()->unsigned()->default(0)->comment('访问次数');
            $table->text('content')->nullable();
            $table->text('introduction')->nullable()->comment('用户简介');
            $table->string('thumbnail',255)->nullable();
            $table->longText('images')->nullable()->comment('图片集合');
            $table->string('qr_code',125)->nullable()->comment('二维码');
            $table->smallInteger('is_using')->nullable()->unsigned()->default(1)->comment('状态');
            $table->timestamps();

            $table->index('vote_id');
            $table->index('title');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    : void
    {
        Schema::dropIfExists('vote_options');
    }
};
